package org.example.Server.controller.semester;

import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.semester.SemDivisonDTO;
import org.example.Server.model.semester.SemStuDivsion;
import org.example.Server.service.semester.SemesterService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/youxich/semester/division")
public class SemDivisionController {
    @Autowired
    SemesterService semesterService;

    /**
     * 获取分班列表
     *
     * @return
     */
    @GetMapping
    public ResultAPI getDivision(@RequestParam Integer semester_id) {
        return semesterService.getDivision(semester_id);
    }

    /**
     * 获取学生列表以及分班
     *
     * @param sem_id
     * @param division_id -1全部0未分班
     * @return
     */
    @GetMapping("/list")
    public ResultAPI getSemStuDivList(@RequestParam Integer sem_id, @RequestParam(required = false) Integer division_id) {
        return semesterService.getSemStuDivList(sem_id, division_id);
    }

    /**
     * 调班
     *
     * @param semStuDivsion
     * @return
     */
    @PutMapping
    public ResultAPI updateStuDivision(@RequestBody SemStuDivsion semStuDivsion) {
        return semesterService.updateStuDivision(semStuDivsion);
    }

    /**
     * 删除分班
     *
     * @param division_id
     * @return
     */
    @DeleteMapping
    public ResultAPI deleteDivision(@RequestParam Integer division_id) {
        return semesterService.deleteDivision(division_id);
    }

    /**
     * 新建分班
     * @param semDivisonDTO
     * @return
     */
    @PostMapping()
    public ResultAPI addDivision(@RequestBody SemDivisonDTO semDivisonDTO) {
        return semesterService.addDivision(semDivisonDTO);
    }
}
